package StringBUilder;

/**
 * @author liuchaoqun
 * @date 2022/9/8
 * @Description
 */
public class StringBuilderTest {
    public static void main(String[] args) {
        VehicleEntity vehicleEntity = new VehicleEntity();
        vehicleEntity.setName("汽车");
        vehicleEntity.setShowVehicleLicense(1);
        vehicleEntity.setShowTransport(1);
        vehicleEntity.setShowVehiclePhoto(1);
        StringBuilder showFiled = new StringBuilder();
        StringBuilder hiddenFiled = new StringBuilder();
        getShowFiledAndHiddenFiled(vehicleEntity, showFiled, hiddenFiled);
        System.out.println(showFiled.toString());
        System.out.println(hiddenFiled);
    }

    public static void getShowFiledAndHiddenFiled(VehicleEntity entity, StringBuilder showFiled, StringBuilder hiddenFiled) {
        if (AdminConstant.SHOW.equals(entity.getShowVehicleLicense())) {
            showFiled.append(AdminConstant.VEHICLE_LICENSE);
            showFiled.append(",");
        } else {
            hiddenFiled.append(AdminConstant.VEHICLE_LICENSE);
            hiddenFiled.append(",");
        }

        if (AdminConstant.SHOW.equals(entity.getShowTransport())) {
            showFiled.append(AdminConstant.TRANSPORT);
            showFiled.append(",");
        } else {
            hiddenFiled.append(AdminConstant.TRANSPORT);
            hiddenFiled.append(",");
        }

        if (AdminConstant.SHOW.equals(entity.getShowVehiclePhoto())) {
            showFiled.append(AdminConstant.VEHICLE_PHOTO);
            showFiled.append(",");
        } else {
            hiddenFiled.append(AdminConstant.VEHICLE_PHOTO);
            hiddenFiled.append(",");
        }

        if (showFiled.length() > 0) {
            showFiled.deleteCharAt(showFiled.length() - 1);
        }

        if (hiddenFiled.length() > 0) {
            hiddenFiled.deleteCharAt(hiddenFiled.length() - 1);
        }
    }
}
